package org.ala.shopping_test;

import com.mysql.cj.xdevapi.Table;
import org.ala.tiktools.sharddb.tools.SnowIdGenerator;
import org.springframework.cglib.core.Local;

import java.sql.Time;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.stream.IntStream;

/**
 * 分库配置信息
 *
 * @author ala
 * @date 2025-03-14 14:17
 */
public class ShardInfos {


    /**
     *  用户中心库
     */
    public static final String[] DB_USER_CENTER = {"user_center"};


    /**
     *  商城中心主库
     */
    public static final String DB_SHOPPING_CENTER_MAIN = "shopping_mail";
    /**
     *  商城中心分库
     */
    public static final String[] DB_SHOPPING_CENTER = {
            "shopping_mail_0",
            "shopping_mail_1",
            "shopping_mail_2",
            "shopping_mail_3",
            "shopping_mail_4",
            "shopping_mail_5",
            "shopping_mail_6",
            "shopping_mail_7",
            "shopping_mail_8",
            "shopping_mail_9",
            "shopping_mail_10",
            "shopping_mail_11"};


    static DateTimeFormatter dateFormater = DateTimeFormatter.ofPattern("yyyyMMdd");
    /**
     *  时间每日分表
     */
    public static String TableEveryDay(long timestamp) {
        return dateFormater.format(Instant.ofEpochMilli(timestamp));
    }


    public static void main(String[] args) {
        SnowIdGenerator idGenerator = SnowIdGenerator.build(1);


        IntStream.range(0, 1000).forEach(i -> {
            SnowIdGenerator.Id id = idGenerator.id();

            System.out.println((int)(id.getId() % DB_SHOPPING_CENTER.length));
        });
    }
}
